<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div>
    <h1>the goods page</h1>
</div>

<table>
    <thead>
        <tr>
            <td>id</td>
            <td>name</td>
            <td>remark</td>
            <td>createdTime</td>
        </tr>
    </thead>
    <tbody id ="tbodyId">
        <tr>
            <td colspan="4">Data is loading...</td>
        </tr>
    </tbody>
</table>
</body>
<script src="js/axios.min.js"></script>
<script>
    window.onload = function () {
        let url = "/doFindGoods"
        axios.get(url).then(function (result) {
            console.log(result.data);
            let data = result.data;
            var tBody = document.getElementById("tbodyId");
            tBody.innerHTML='';//清空原有body内容
            // var tr='';
            // for (var i = 0; i < result.data.length; i++) {//循环一次,迭代一行
            //     //构建当前行对象
            //     tr = `${tr} <tr>
            //               <td>${result.data[i].id}</td>
            //               <td>${result.data[i].name}</td>
            //               <td>${result.data[i].remark}</td>
            //               <td>${result.data[i].createdTime}</td>
            //              </tr>`
            // }
            // tBody.innerHTML=tr;

            data.forEach(function (item) {
                let tr =document.createElement("tr");

                var td =document.createElement("td");
                td.innerText=item.id
                tr.append(td);
                var td =document.createElement("td");
                td.innerText=item.name
                tr.append(td);
                var td =document.createElement("td");
                td.innerText=item.remark
                tr.append(td);
                var td =document.createElement("td");
                td.innerText=item.createdTime
                tr.append(td);

                tBody.appendChild(tr);
            });

        }).catch(function (e) {
            console.log(e);
        });
    }
</script>
</html>